<template>
  <div class="app-container">
    <template>
      <el-table :data="list" stripe fit highlight-current-row  style="width: 100%">
      <el-table-column align="center" label="ID" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.cid }}</span>
        </template>
      </el-table-column>  

      <el-table-column label="标题" width="280">
        <template slot-scope="scope">
          <el-link type="primary" :underline="false" :href="scope.row.permalink" target="_blank" style="font-size:10px">{{ scope.row.title }}</el-link>
        </template>
      </el-table-column>  
        <el-table-column label="创建时间" width="180">
            <template slot-scope="scope">
              <span>{{ scope.row.year }}.{{scope.row.month}}.{{scope.row.day}}</span>
            </template>
        </el-table-column>
        <el-table-column  label="标签">
            <template slot-scope="scope">
              <el-tag v-for="item in scope.row.categories" :key="item.name">{{ item.name }}</el-tag>
            </template>          
        </el-table-column>
        <el-table-column  label="描述">
            <template slot-scope="scope">
              <span>{{ scope.row.description[0].str_value }}</span>
            </template>
        </el-table-column>        
      </el-table>
    </template>

  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import Axios from 'axios'

export default {
  name: 'ArticleList',
  components: { Pagination },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'info',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      url: 'https://miniprogram.ansibleui.cn/api/posts',
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        pageSize: 20,
        apisec: 'DSfewfEWc2e'
      }
    }
  },
  created() {
    this.getList()


  },
  methods: {
    getList() {
      // this.listLoading = true
      // fetchList(this.listQuery).then(response => {
      //   this.list = response.data.items
      //   this.total = response.data.total
      //   this.listLoading = false
      // })
      Axios.get(this.url, {params: this.listQuery}).then(resp => {
        this.list=resp.data.data
        this.listLoading = false
      })
    }
  }
}
</script>

<style scoped>
.edit-input {
  padding-right: 100px;
}
.cancel-btn {
  position: absolute;
  right: 15px;
  top: 10px;
}
</style>
